import 'package:flutter/material.dart';
import 'package:gif/gif.dart';
import '../../home/homeView/product_search_view.dart';

typedef SearchActionCallback = void Function();
typedef SearchKeyCallback = void Function(String key);
typedef PushContactCallback = void Function();

class CategoryTopView extends StatefulWidget {
  final PushContactCallback onContact;
  final SearchActionCallback onSearchAction;

  const CategoryTopView({
    super.key,
    required this.onContact,
    required this.onSearchAction,
  });

  @override
  State<CategoryTopView> createState() => _CategoryTopViewState();
}

class _CategoryTopViewState extends State<CategoryTopView> with SingleTickerProviderStateMixin {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;

    return SizedBox(
      height: 155,
      child: Stack(        
        children: [
          Positioned(
            top: MediaQuery.of(context).padding.top ,
            left: screenWidth / 2 - 70,
            child: Image.asset(
              'assets/images/verIcon.png',
              width: 140,
              height: 44,
            ),
          ),
          Positioned(
            top: MediaQuery.of(context).padding.top ,
            right: 14,
            child: GestureDetector(
              onTap: widget.onContact,
              child: Gif(
                fps: 10,
                autostart: Autostart.loop,
                image: AssetImage('assets/images/kefu_logo2.gif'),
                width: 44,
                height: 44,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            top: MediaQuery.of(context).padding.top + 44 + 14,
            left: 15,
            right: 15,
            child: ProductSearchView(
              onTap: widget.onSearchAction,
            ),
          ),
        ],
      ),
    );
  }
}